package org.weishe.pagerank.hbase;

import java.io.IOException;
import java.text.DecimalFormat;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.util.StringUtils;

public class EndMapper extends Mapper<Text, Text, DoubleWritable, Text> {
	DecimalFormat df = new DecimalFormat("######0.0000");
	private DoubleWritable oKey = new DoubleWritable();

	@Override
	protected void map(Text key, Text value, Mapper<Text, Text, DoubleWritable, Text>.Context context)
			throws IOException, InterruptedException {
		String str[] = StringUtils.split(value.toString(), ',');
		String d = df.format(Double.parseDouble(str[0]));
		oKey.set(Double.parseDouble(d));
		context.write(oKey, key);
	}

}
